
var swfu = null;
var vcc = 0;

window.onload = function ()
{
			swfu = new SWFUpload(
			{
				// Backend Settings
				upload_url: "swfupload.php",
				post_params: {"PHPSESSID": "<?php echo session_id(); ?>", "dopost" : ""},

				// File Upload Settings
				file_size_limit : "2 MB",	// 2MB
				file_types : "*.jpg; *.gif; *.png",
				file_types_description : "选择 JPEG/GIF/PNG 格式图片",
				file_upload_limit : "0",

				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,

				button_image_url : "img/41.gif",
				button_placeholder_id : "spanButtonPlaceholder",
				button_width: 316,
				button_height: 30,
				button_text : '<span class="button" >选择本地图片 <span class="buttonSmall">(单图最大为 2 MB，支持多选)</span></span>',
				button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 16pt;} .buttonSmall { font-size: 12pt; }',
				button_text_top_padding: 0,
				button_text_left_padding: 18,
				button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				button_cursor: SWFUpload.CURSOR.HAND,
				
				// Flash Settings
				flash_url : "../img/swfupload/swfupload.swf",

				custom_settings : {
					upload_target : "divFileProgressContainer"
				},
				
				// Debug Settings
				debug: false
			});
};






 var i=0;

  var all = document.getElementsByTagName('*') ;
  function addNew(){
	  
    var tr=all.t136.insertRow(-1);
    i++;	
    tr.insertCell(-1).innerHTML='日期：<input type=\'text\' name=date'+i+' id=date'+(i-1)+' />&nbsp;&nbsp;成人价：<input type=\'text\' name=cr'+i+' />&nbsp;&nbsp;儿童价：<input type=\'text\' name=rt'+i+' />&nbsp;&nbsp;简要说明：<input type=\'text\' name=sm'+i+' />&nbsp;&nbsp;<a href=\'javascript:void(0)\' onclick=\'del(event);\' >删除</a> <input type=\'hidden\' name=hdate0 id=date0 />';
	
	         $ = function(o) { return typeof o === "string" ? document.getElementById(o) : o };
	        var ma = [["1","3","5","7","8","10"],["4","6","9","11"]];
            var dd = new Date();
            var x = dd.toLocaleString();
            var o = pasDate(x);
            $("date0").value = o.join("-");

            //转化日期函数
            function pasDate(da) {
                var yp = da.indexOf("年"),
               mp = da.indexOf("月"),
               dp = da.indexOf("日");
                var y = da.substr(0,yp),
               m = da.substr(yp + 1,mp - yp - 1),
               d = da.substr(mp + 1,dp - mp - 1);
                return [y,m,d];
            }


            //判断数组a是否存在在元素n
            function check(n,a) {
                for(var i = 0,len = a.length;i < len;i++) {
                    if(a[i] == n) {
                        return true;
                    }
                }
                return false;
            }

            //闰?年?
            function isLeap(y) {
                return ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) ? true : false;
            }
            //实现加减f："1"加，"0"减
            function trans(o,f) {
                var d = o.split("-");
                var l = isLeap(d[0]);

                if(f == "1") {
                    if((check(d[1],ma[0]) && (d[2] == "31")) || (check(d[1],ma[1]) && (d[2] == "30")) ||
                              (d[1] == "2" && d[2] == "28" && !l) || (d[1] == "2" && d[2] == "29" && l)) {
                        return d[0] + "-" + (d[1] * 1 + 1) + "-" + 1;
                    } else if(d[1] == "12" && d[2] == "31") {
                        return (d[0] * 1 + 1) + "-" + "1-1";
                    } else {
                        return d[0] + "-" + d[1] + "-" + (d[2] * 1 + 1);
                    }

                } else if(f == "0") {
                    if(check(d[1] - 1,ma[0]) && (d[2] == "1")) {
                        return d[0] + "-" + (d[1] - 1) + "-" + "31";
                    } else if(check(d[1] - 1,ma[1]) && (d[2] == "1")) {
                        return d[0] + "-" + (d[1] - 1) + "-" + "30";
                    } else if(d[1] == "1" && d[2] == "1") {
                        return (d[0] - 1) + "-" + "12-31";
                    } else if(d[1] == "3" && d[2] == "1" && !l) {
                        return d[0] + "-" + "2-28";
                    } else if(d[1] == "3" && d[2] == "1" && l) {
                        return d[0] + "-" + "2-29";
                    } else {
                        return d[0] + "-" + d[1] + "-" + (d[2] - 1);
                    }
                } else {
                    return;
                }

            }
		   var v = $("date"+(i-1)+"").value;
           $("date"+i+"").value = trans(v,"1");
			
			
	var p;
	if(document.getElementById('alll').value==0)
	{
	p=0;
	}
	else
	{
		p=document.getElementById('alll').value;
		
	}
	 var r=Number(p)+1
	 document.getElementById('alll').value=r;
     reset_input_name();
}
 
function del(e){
     e = window.event||e;
    var srcElement=e.srcElement||e.target; 
    all.t136.deleteRow(srcElement.parentNode.parentNode.rowIndex);
	document.getElementById('alll').value=document.getElementById('alll').value-1;
	i--;
    reset_input_name();
 }
 
 function reset_input_name()
 {
    var pic_number=all.t136.rows.length-2;
     all.pic_number.value=pic_number;
    var trr=all.t136.getElementsByTagName('tr');
	
    var b=1;
    for(var j=2;j<trr.length;j++)
    {
		/*
         trr[j].childNodes[0].childNodes[0].setAttribute('name','cr'+(b)+'');
         trr[j].childNodes[0].childNodes[0].setAttribute('name','rt'+(b)+'');
		 trr[j].childNodes[0].childNodes[0].setAttribute('name','sm'+(b)+'');
         b++;
		 */
    }
	
 }
 
   var ii=0;
   function addNew7(){
     var tr=all.t137.insertRow(-1);

    ii++;
    tr.insertCell(-1).innerHTML='日期段：从<input type=\'text\' name=datee'+ii+' id=datee'+ii+' />到<input type=\'text\' name=dateee'+ii+' id=dateee'+ii+' />&nbsp;&nbsp;成人价：<input type=\'text\' name=crr'+ii+' />&nbsp;&nbsp;儿童价：<input type=\'text\' name=rtt'+ii+' />&nbsp;&nbsp;简要说明：<input type=\'text\' name=smm'+ii+' />&nbsp;&nbsp;<a href=\'javascript:void(0)\' onclick=\'dell(event);\' >删除</a>';
	
	  $ = function(o) { return typeof o === "string" ? document.getElementById(o) : o };
	   var ma = [["1","3","5","7","8","10"],["4","6","9","11"]];
            var dd = new Date();
            var x = dd.toLocaleString();
            var o = pasDate(x);
			if(ii==1)
			{
	       $("datee"+ii+"").value = o.join("-");
			}
			else
			{
			$("datee"+ii+"").value=$("dateee"+(ii-1)+"").value;	
			}
			
	        var mm=$("pl").value;
			mm=parseInt(mm);
	 //转化日期函数
            function pasDate(da) {
                var yp = da.indexOf("年"),
               mp = da.indexOf("月"),
               dp = da.indexOf("日");
                var y = da.substr(0,yp),
               m = da.substr(yp + 1,mp - yp - 1),
               d = da.substr(mp + 1,dp - mp - 1);
                return [y,m,d];
            }


            //判断数组a是否存在在元素n
            function check(n,a) {
                for(var i = 0,len = a.length;i < len;i++) {
                    if(a[i] == n) {
                        return true;
                    }
                }
                return false;
            }

            //闰?年?
            function isLeap(y) {
                return ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) ? true : false;
            }
            //实现加减f："1"加，"0"减
            function trans(o,f) {
                var d = o.split("-");
                var l = isLeap(d[0]);

                if(f == "1") {
                    if((check(d[1],ma[0]) && (d[2] == "31")) || (check(d[1],ma[1]) && (d[2] == "30")) ||
                              (d[1] == "2" && d[2] == "28" && !l) || (d[1] == "2" && d[2] == "29" && l)) {
                        return d[0] + "-" + (d[1] * 1 + 1) + "-" + mm;
                    } else if(d[1] == "12" && d[2] == "31") {
                        return (d[0] * 1 + 1) + "-" + "1-1";
                    } else {
                        return d[0] + "-" + d[1] + "-" + (d[2] * 1 + mm);
                    }

                } else if(f == "0") {
                    if(check(d[1] - 1,ma[0]) && (d[2] == "1")) {
                        return d[0] + "-" + (d[1] - 1) + "-" + "31";
                    } else if(check(d[1] - 1,ma[1]) && (d[2] == "1")) {
                        return d[0] + "-" + (d[1] - 1) + "-" + "30";
                    } else if(d[1] == "1" && d[2] == "1") {
                        return (d[0] - 1) + "-" + "12-31";
                    } else if(d[1] == "3" && d[2] == "1" && !l) {
                        return d[0] + "-" + "2-28";
                    } else if(d[1] == "3" && d[2] == "1" && l) {
                        return d[0] + "-" + "2-29";
                    } else {
                        return d[0] + "-" + d[1] + "-" + (d[2] - 1);
                    }
                } else {
                    return;
                }

            }
			
			 var v = $("datee"+ii+"").value;
           $("dateee"+ii+"").value = trans(v,"1");
	
	var p;
	if(document.getElementById('allll').value==0)
	{
	p=0;
	}
	else
	{
		p=document.getElementById('allll').value;
		
	}
	 var r=Number(p)+1
	 document.getElementById('allll').value=r;
	
     reset_input_name();
}
 
 function dell(e){
     e = window.event||e;
    var srcElement=e.srcElement||e.target; 
    all.t137.deleteRow(srcElement.parentNode.parentNode.rowIndex);
	document.getElementById('allll').value=document.getElementById('allll').value-1;
	ii--;
    reset_input_name();
 }


